package com.eqdd.yiqidian.ui.mine.shenqing;

import android.os.Bundle;
import android.view.View;

import com.eqdd.annotation.datasave.DealCodeClass;
import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.box.ItemDecoration.SectionDividerItemDecoration;
import com.eqdd.yiqidian.base.CodeRule;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.bean.EnterBean;
import com.eqdd.yiqidian.bean.rebuild.CommonTabBean;
import com.eqdd.yiqidian.bean.rebuild.LayoutMapBean;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.ui.base.BaseEnterActivity;
import com.eqdd.yiqidian.ui.mine.pizhun.LeaveInfoActivity;
import com.eqdd.yiqidian.ui.mine.pizhun.MissClockInfoActivity;
import com.eqdd.yiqidian.ui.mine.pizhun.MyPiZhunInfoActivity;
import com.eqdd.yiqidian.ui.mine.pizhun.OffInfoActivity;
import com.eqdd.yiqidian.ui.mine.pizhun.SickLeaveInfoActivity;
import com.eqdd.yiqidian.ui.mine.qiye.ShowMyContractActivity;
import com.eqdd.yiqidian.utils.DensityUtil;
import com.eqdd.yiqidian.utils.ToastUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lvzhihao on 17-5-20.
 */

public class MyShenqingActivity extends BaseEnterActivity {
    private Class[] classes = new Class[]{
            ShowMyQingjiaActivity.class,
            ShowMyTravelActivity.class,
            ShowMyOverTimeActivity.class,
            ShowMyTiaoXiuActivity.class,
            ShowMyChangeShiftActivity.class,
            ShowMyChidaoZaotuiActivity.class,
            ShowMyLoudakaActivity.class,
            ShowMyCarActivity.class,
            ShowMyNewsActivity.class,
            ShowMyContactBookActivity.class,
            ShowMyLizhiActivity.class,
            ShowMyRenliActivity.class,
            ShowMyTrainActivity.class,
            ShowMyTiaoGangActivity.class,
    };
    private List<CommonTabBean> commonTabBeans = new ArrayList<>();
    private CommonTabBean lizhiCommonTabBean;

    @Override
    public void itemClick(int p) {

        if (commonTabBeans.get(p) != null) {
            Bundle bundle = new Bundle();
            bundle.putSerializable("bean", commonTabBeans.get(p));
            startActivity(classes[p], bundle);
        } else if (classes[p] != null) {
            /*if (p == 8) { //通知
                if (user.isIsleader()) {
                    startActivity(classes[p]);
                } else {
                    ToastUtil.showShort("你没有权限发布通知");
                }
            } else {
                startActivity(classes[p]);
            }*/
            startActivity(classes[p]);
        } else {
            ToastUtil.showShort("该模块暂未开发");
        }

    }

    @Override
    public void initEnterData() {
        isDealCode = true;
        initTopTitleBar(View.VISIBLE, "我的申请");
        enterBeans.add(new EnterBean("请假").setCode(CodeRule.SHENGQING_QINGJIA));
        enterBeans.add(new EnterBean("出差").setCode(CodeRule.SHENGQING_CHUCHAI));
        enterBeans.add(new EnterBean("加班").setCode(CodeRule.SHENGQING_JIABAN));
        enterBeans.add(new EnterBean("调休").setCode(CodeRule.SHENGQING_TIAOXIU));
        enterBeans.add(new EnterBean("调班").setCode(CodeRule.SHENGQING_TIAOBAN));
        enterBeans.add(new EnterBean("迟到早退").setCode(CodeRule.SHENGQING_CHIDAOZAOTUI));
        enterBeans.add(new EnterBean("漏打卡").setCode(CodeRule.SHENGQING_LOUDAKA));
        enterBeans.add(new EnterBean("用车申请"));
        enterBeans.add(new EnterBean("通知"));
        enterBeans.add(new EnterBean("联络书").setCode(CodeRule.SHENGQING_LIANLUOSHU));
        enterBeans.add(new EnterBean("离职申请").setCode(CodeRule.SHENGQING_LIZHI));
        enterBeans.add(new EnterBean("人力需求"));
        enterBeans.add(new EnterBean("培训"));
        enterBeans.add(new EnterBean("调岗"));

        commonTabBeans.add(new CommonTabBean("请假列表", Config.APPLY_QINGJIA,
                ApplyLeaveActivity.class)
                .title("待审核", "已审核")
                .setIdName("leaveId")
                .setInfoActivity(LeaveInfoActivity.class)
                .setLayoutId(R.layout.list_item_28)
                .map(new LayoutMapBean(R.id.tv_left_content, "getThird"),
                        new LayoutMapBean(R.id.tv_right_hint_content, "getSecond").setTime(true))
                .setUrl(HttpConfig.MY_CREATE_LEAVE_LIST));
        commonTabBeans.add(null);
        commonTabBeans.add(null);
        commonTabBeans.add(new CommonTabBean("调休列表", Config.APPLY_OFF,
                ApplyOffActivity.class)
                .title("待审核", "已审核")
                .setIdName("offId")
                .setInfoActivity(OffInfoActivity.class)
                .setLayoutId(R.layout.list_item_12)
                .map(new LayoutMapBean(R.id.tv_upper_left_content, 3),
                        new LayoutMapBean(R.id.tv_down_left_content, 4),
                        new LayoutMapBean(R.id.tv_upper_right_content, "getSecond").setTime(true),
                        new LayoutMapBean(R.id.tv_down_right_content, 5))
                .setUrl(HttpConfig.MY_OFF_CREATE_LIST));

        commonTabBeans.add(null);
        commonTabBeans.add(new CommonTabBean("迟到早退消除列表", Config.APPLY_SICK_LEAVE,
                ApplySickLeaveActivity.class)
                .title("待审核", "已审核")
                .setIdName("sickleaveId")
                .setInfoActivity(SickLeaveInfoActivity.class)
                .setLayoutId(R.layout.list_item_28)
                .map(new LayoutMapBean(R.id.tv_left_content, 6),
                        new LayoutMapBean(R.id.tv_right_hint_content, 7))
                .setUrl(HttpConfig.MY_SICK_LEAVE_LIST));
        commonTabBeans.add(new CommonTabBean("漏打卡列表", Config.APPLY_MISS_CLOCK,
                ApplyMissClockActivity.class)
                .title("待审核", "已审核")
                .setIdName("missClockId")
                .setInfoActivity(MissClockInfoActivity.class)
                .setLayoutId(R.layout.list_item_28)
                .map(new LayoutMapBean(R.id.tv_left_content, 8),
                        new LayoutMapBean(R.id.tv_right_hint_content, 7))
                .setUrl(HttpConfig.MY_MISS_CLOCK_LIST));
        commonTabBeans.add(null);
        commonTabBeans.add(null);
        commonTabBeans.add(null);
        lizhiCommonTabBean = new CommonTabBean("离职申请列表", Config.APPLY_LIZHI,
                ApplyLizhiActivity.class)
                .title("申请中", "已审批", "未审批")
                .setIdName("quitId")
                .setWho(0)
                .setInfoActivity(MyPiZhunInfoActivity.class)
                .setLayoutId(R.layout.list_item_13)
                .map(new LayoutMapBean(R.id.tv_left_center_content, "getSix"),
                        new LayoutMapBean(R.id.tv_upper_right_content, 1),
                        new LayoutMapBean(R.id.tv_down_right_content, 2))
                .setUrl(HttpConfig.APPALY_LIZHI_LIST);
        commonTabBeans.add(lizhiCommonTabBean);
        commonTabBeans.add(null);
        commonTabBeans.add(null);
        commonTabBeans.add(new CommonTabBean("调岗列表", Config.APPLY_TIAOGANG,
                ApplyOffActivity.class)
                .title("待审核", "已审核")
                .setIdName("offId")
                .setInfoActivity(OffInfoActivity.class)
                .setLayoutId(R.layout.list_item_12)
                .map(new LayoutMapBean(R.id.tv_upper_left_content, 3),
                        new LayoutMapBean(R.id.tv_down_left_content, 4),
                        new LayoutMapBean(R.id.tv_upper_right_content, "getSecond").setTime(true),
                        new LayoutMapBean(R.id.tv_down_right_content, 5))
                .setUrl(HttpConfig.MY_TIAOGANG_CREATE_LIST));
        dataBinding.recyclerView.addItemDecoration(
                new SectionDividerItemDecoration(this, 7, 1, 7)
                        .setHeadHeight(DensityUtil.percentW(50))
                        .setLeftPadding(DensityUtil.percentW(30))
                        .setRightPadding(DensityUtil.percentW(30))
                        .setTitle("考勤", "后勤", "组织管理"));


    }

    @DealCodeClass(classes = {ShowMyQingjiaActivity.class})
    public void updateQingjia(int num) {

        updateNum(0);
    }

    @DealCodeClass(classes = {ShowMyTravelActivity.class})
    public void updateChuchai(int num) {
        updateNum(1);

    }

    @DealCodeClass(classes = {ShowMyOverTimeActivity.class})
    public void updateJiaban(int num) {
        updateNum(2);

    }

    @DealCodeClass(classes = {ShowMyTiaoXiuActivity.class})
    public void updateTiaoxiu(int num) {
        updateNum(3);

    }

    @DealCodeClass(classes = {ShowMyChangeShiftActivity.class})
    public void updateTiaoban(int num) {
        updateNum(4);

    }

    @DealCodeClass(classes = {ShowMyChidaoZaotuiActivity.class})
    public void updateChidaozaotui(int num) {
        updateNum(5);

    }

    @DealCodeClass(classes = {ShowMyLoudakaActivity.class})
    public void updateLoudaka(int num) {
        updateNum(6);

    }


   /* @DealCodeClass(classes = {ShowMyContractActivity.class})
    public void updateLianluoshu(int num) {
        updateNum(10);

    }*/

    @DealCodeClass(classes = {ShowMyLizhiActivity.class})
    public void updateLizhi(int num) {
        updateNum(10);

    }
}
